import sim, sim_items, main
from util import *
import random

class AtlasPrefix(sim_items.Prefix):
    def __init__(self):
        super(AtlasPrefix, self).__init__(
            "atlas", # name
            "Infused with the strength of ancient chthonic giants, this "
            "items allows one to bear the weight of the world."
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Armor):
            raise ValueError('Tried to apply %r to non-armor item: %r' % (self,
                wearable))
        if 'arms' not in wearable.wearSlots:
            return 
        super(AtlasPrefix, self).initialize(wearable)
        
        capacityBonus = random.randint(25,50)
        self.wearable.bonuses.update({
            'capacityMod': self.wearable.bonuses['capacityMod'] + capacityBonus, 
        })

    def remove(self, wearable):
        super(AtlasPrefix, self).remove(wearable)
        wearable.bonuses.update({
            'capacityMod': self.wearable.bonuses['capacityMod'] - capacityBonus,
        })

#========================================
thingClass = AtlasPrefix
